#导入socket
from socket import *
import time

def worker(newstr,newadder):
    udpSocket.sendto(newstr.encode("gb2312"),newadder)

def getInputStr(newMsg):
    newStr = "1:12312312312:神秘来客:神秘来客:32:" + newMsg
    return newStr
def getInputAdder(newIp):
    adder = (newIp,2425)
    return adder

if __name__ == '__main__':
    # 创建socket
    udpSocket = socket(AF_INET, SOCK_DGRAM)
    # 获取数据

    # newadder = getInputAdder(input("对方ip:"))
    # newstr = getInputStr(input("要轰炸的消息："))

    for i in range(0,256):
        ip = "192.168.13."+str(i)
        worker(getInputStr("t"), getInputAdder(ip))

    # 发送数据
    # while True:
    #     worker(newstr, newadder)
    #     time.sleep(10)
    #     print("完成！")


    # 关闭socket
    udpSocket.close()